/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
/**
* Classe ContactListCellRender permet de colorer un element selectionné dans la liste des contacts
* @author      Frank Djomo
 * @author      Christelle SIAGO HAPPI
 * @author      djomopoueme@gmail.com
 * @author      christelle.siagohappi@gmail.com
* @version     1.0
*/
public class ContactListCellRender implements ListCellRenderer
{

    @Override
    public Component getListCellRendererComponent(JList jlist, 
                                                Object value, 
                                                int cellIndex, 
                                                boolean isSelected, 
                                                boolean cellHasFocus)
    {
        if (value instanceof JPanel)
        {
          Component component = (Component) value;
          component.setForeground (Color.white);
          component.setBackground (isSelected ? Color.PINK : Color.white);
          return component;
        }
        else
        {
          // TODO - I get one String here when the JList is first rendered; proper way to deal with this?
          //System.out.println("Got something besides a JPanel: " + value.getClass().getCanonicalName());

           return new JLabel();
        }
    }
}
